package com.daatak.mvc.common;
import java.io.IOException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class HtmlTd extends BodyTagSupport
{
 private String attributes;
 private String append;

  public void setBodyContent(BodyContent bc)
  {
    super.setBodyContent(bc);
    //System.out.println("BodyContent = '" + bc.getString() + "'");
  }
  
  public int doAfterBody()
  {
    try 
    {    
      BodyContent bodyContent = super.getBodyContent();
      String      bodyString  = bodyContent.getString();
      JspWriter   out         = bodyContent.getEnclosingWriter();
      if(append==null || "".equals(append))
    	  out.println("<td "+attributes+">"+bodyString+"</td>");
      else
    	  out.println("<td><"+append+" class='innerTD'> "+bodyString+"</"+append+"></td>");
    	  
      bodyContent.clear(); // empty buffer for next evaluation
    }
    catch (IOException e) 
    {
      //System.out.println("Error in BodyContentTag.doAfterBody()" + e.getMessage());
      e.printStackTrace();
    } // end of catch

    int retValue = SKIP_BODY;
    
   
    
    return retValue;
  }

public String getAttributes() {
	return attributes;
}

public void setAttributes(String attributes) {
	this.attributes = attributes;
}

public String getAppend() {
	return append;
}

public void setAppend(String append) {
	this.append = append;
}
}